<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>EAS</title>
    <script src="../jq/jquery.min.js"></script>
    <script src="./crypto-js.js"></script>
    <script src="./encrypted.js"></script>
  </head>
  <body>
    <div>EAS</div>
    <input type="text" id="val" />
    <button id="btn" click="encryptedEvent">加密解密</button>
    <div id="mi"></div>
    <div id="msg"></div>
    <script>
      (() => {
        $("#btn").on("click", function encryptedEvent() {
          let val = $("#val").val();
          encryptedAES(val+'')
        //   if(val) return;
          const keyEncryted = AES.CBCEncrypt("82c22b07c5654dcf",'04d702509d7e45bd', val);
        //   const keyEncryted =  '"' + AES.ECBEncrypt("82c22b07c5654dcf", val) + '"';
          $("#mi").text(keyEncryted);
          $.ajax({
            url: "http://192.168.10.223:9101/course/testAes",
            type: "post",
            dataType: "json",
            contentType:"application/json",
            data: JSON.stringify({ content: keyEncryted }),
            success: function (msg) {
              $("#msg").text(JSON.stringify(msg));
            },
            catch: (err) => {
              $("#msg").text(JSON.stringify(err));
              $("#msg").attr("style", "color:red;");
            },
          });
        });
      })();
    </script>
  </body>
</html>
